@mixin text-style($weight: normal, $size: 16px, $line-height: 150%, $max-width: 640px) {
  max-width: $max-width;
  font-size: $size;
  font-weight: $weight;
  line-height: $line-height;
}

// Due to the recursive rendering every sub-element has the safe-html class applied
// so we use these compound selectors to specify styling.
h1.safe-html {
  @include text-style(bold, 32px, 130%);

  margin: 32px auto 24px;
}

h2.safe-html {
  @include text-style(bold, 28px, 130%);

  margin: 24px auto 16px;
}

h3.safe-html {
  @include text-style(bold, 24px, 130%);

  margin: 12px auto;
}

h4.safe-html {
  @include text-style(600, 20px, 130%);

  margin: 8px auto;
}

h5.safe-html {
  @include text-style(600, 18px, 130%);

  margin: 8px auto;
}

h6.safe-html {
  @include text-style(600, 16px, 130%);

  margin: 8px auto;
}

p.safe-html {
  @include text-style();

  margin: 8px auto;
}

ul.safe-html,
ol.safe-html {
  @include text-style();

  padding-left: 24px;
  margin: 8px auto;
}

li.safe-html {
  margin-left: 18px;
}

li.safe-html ~ li.safe-html {
  margin-top: 4px;
}

dl.safe-html {
  max-width: 640px;
  margin: 8px auto;
}

dt.safe-html {
  @include text-style(600);
}

dd.safe-html {
  @include text-style();

  padding-left: 24px;
  margin-top: 4px;
  margin-left: 0;
}

strong.safe-html,
b.safe-html {
  @include text-style(bold);
}

.table-container {
  width: calc(100% + 32px);
  padding: 0 16px;
  margin-left: -16px;
  overflow-x: auto;
}

.table-container:focus-visible {
  outline: 3px solid rgb(51, 172, 245) !important;
  outline-offset: -3px !important;
}

table.safe-html {
  min-width: 640px;
  margin: 16px auto;
  font-size: 16px;
  table-layout: fixed;
  border-collapse: collapse;
  border: 1px solid var(--color-grey-300);
}

caption.safe-html {
  margin: 0 auto 12px;
  font-weight: 600;
  color: var(--color-primary-500);
}

caption.safe-html.small-window {
  text-align: start;
}

thead.safe-html {
  font-weight: 600;
  background-color: var(--color-primary-100);
}

tfoot.safe-html {
  background-color: var(--color-grey-100);
}

th.safe-html {
  font-weight: 600;
  text-align: left;
}

th.safe-html,
td.safe-html {
  min-width: 200px;
  padding: 16px;
  border: 1px solid var(--color-grey-300);
}

.image-container {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 1200px;
  max-height: 80vh;
  margin: 16px auto;
}

.img-wrapper {
  position: relative;
  display: inline-block;
  transition: box-shadow 0.15s;
}

.img-wrapper:hover {
  cursor: pointer;
  box-shadow:
    3px 0 8px 1px rgba(16, 24, 40, 0.1),
    -3px 6px 8px 1px rgba(16, 24, 40, 0.1);
}

img.safe-html {
  display: block;
  max-width: 100%;
  max-height: 80vh;
  margin: 0 auto;
  border: 1px solid var(--color-fineline);
}

.expand-btn {
  position: absolute;
  top: 13px;
  right: 13px;
  opacity: 0;
}

.img-wrapper:hover .expand-btn,
.expand-btn:focus {
  opacity: 1;
}

math.safe-html {
  @include text-style(normal, 32px, 130%);

  margin: 8px auto;
}
